from django.db import models
from django.contrib.admin.widgets import AdminDateWidget
from django.forms.widgets import HiddenInput

# must import ModelForm
from django.forms import ModelForm

from django import forms




# Create your models here.
class client(models.Model):

    name=models.CharField(max_length=50)
    age=models.IntegerField(max_length=50)
    country=models.CharField(max_length=50)
    email=models.EmailField(max_length=50)

    password=models.CharField(max_length=50)



    def __unicode__(self):

        return "{0} {1} {2} {3} {4} {5}".format(
            self, self.name, self.age, self.country, self.email,self.password)




######################################
class loginForm(ModelForm):
    class Meta:
        model = client

############################## to add table hotels by admin ########################################
'''
        
class Hotels(models.Model):
    hotel_name=models.CharField(max_length=50)
    country=models.CharField(max_length=50)

    room_type=models.CharField(max_length=10)
    room_price=models.IntegerField()
    room_desc=models.CharField(max_length=50)

    busy_start=models.DateField()
    busy_end=models.DateField()


def __unicode__(self):

    return "{0} {1} {2} {3} ".format(
        self, self.hotel_name, self.country,self.room_type,self.room_desc)

# avalability check

class searchForm(ModelForm):
    class Meta:
        model = Hotels

'''

class Hotels(models.Model):
    hotel_name=models.CharField(max_length=50)
    country=models.CharField(max_length=50)

    #image=models.ImageField(upload_to='/home/amira/Django-1.6.3/django_pro/static/images')

#models.ImageField(upload_to = 'pic_folder/', default = 'pic_folder/None/no-img.jpg')
#default = '/home/amira/Django-1.6.3/django_pro/static/images/3page-img13.jpg'

def __unicode__(self):

    return "{0} {1}".format(
        self, self.hotel_name, self.country)


class searchForm(ModelForm):
    class Meta:
        model = Hotels

############################## to add table rooms by admin ########################################
class Room(models.Model):
    #foreignkey to hotels
    hotel_id = models.ForeignKey(Hotels)

    room_type=models.CharField(max_length=10)
    room_price=models.IntegerField()
    room_desc=models.CharField(max_length=50)


    #busy_start=models.DateField()
    #busy_end=models.DateField()

def __unicode__(self):

    return "{0} {1}".format(
        self,self.room_type,self.room_desc)

class roomForm(ModelForm):
    class Meta:
        model = Room

############################## to add table Dtaes by admin ########################################
class Date(models.Model):
    #foreignkey to hotels
    room_id = models.ForeignKey(Room)
    #hotel_for_id = models.ForeignKey(Hotels)


    #hotel_name_room=models.CharField(max_length=50)
    busy_start=models.DateField()
    busy_end=models.DateField()
    reserve_user = models.CharField(max_length=20)


def __unicode__(self):

    return "{0} {1}".format(

        self,self.room_type,self.reserve_user)

class dateForm(ModelForm):
    class Meta:
        model = Date


######################### to add table review by user #############################################

class Review(models.Model):
    myreview = models.TextField(max_length=100)
    myreview_user = models.CharField(max_length=20)
    # to show calernder
    myreview_date = models.DateField()
    myreview_id = models.ForeignKey(Hotels)



def __unicode__(self):

    return "{0}".format(
        self, self.myreview_user)


class reviewForm(ModelForm):
    class Meta:
        model = Review

        fields = ('myreview', 'myreview_user', 'myreview_date','myreview_id')
        widgets = {
        'myreview_date': AdminDateWidget,

        }



